//
//  SendPresentCollectionViewCell.m
//  SendPresent
//
//  Created by hcl on 16/4/27.
//  Copyright © 2016年 hclong. All rights reserved.
//

#import "HCLPhotoCell.h"
@interface HCLPhotoCell ()

@property (nonatomic, weak) UIImageView *viewImgView;


@end
@implementation HCLPhotoCell

//对号图片
- (UIImageView *)selectImageView {
    if (!_selectImageView ) {
        UIImageView *selectImageView = [[UIImageView alloc] init];
//        修改对号图片大小
        selectImageView.frame = CGRectMake(self.frame.size.width - 27, 5, 22, 22);
        selectImageView.image = [UIImage imageNamed:@"baiban_select.png"];
        [self.contentView addSubview:selectImageView];
        _selectImageView = selectImageView;
    }
    return _selectImageView;
}
//选择按钮
- (UIButton *)selectPhotoButton {
    if (!_selectPhotoButton) {
        
    
        UIButton *selectPhotoButton = [[UIButton alloc] init];
    
        selectPhotoButton.frame = CGRectMake(self.frame.size.width - 27, 0, 27, 27);

        [selectPhotoButton addTarget:self action:@selector(selectPhotoButtonClick:) forControlEvents:UIControlEventTouchUpInside];
        [self.contentView addSubview:selectPhotoButton];
    
        _selectPhotoButton = selectPhotoButton;
    }
    return _selectPhotoButton;
}
//点击按钮触发事件
- (void)selectPhotoButtonClick:(UIButton *)sender {
   
    _changed(self.isSelected);
    if (!self.isSelected) {
         NSLog(@"选中");
        self.selectImageView.image = [UIImage   imageNamed:@"baiban_select_action.png"];
        self.isSelected = YES;
        
    }else{
     NSLog(@"取消");
        self.selectImageView.image =[UIImage   imageNamed:@"baiban_select.png"];
        self.isSelected = NO;}

}
//图片名字
-(UILabel *)label{
    if (!_label) {
        UILabel * label = [[UILabel alloc]init];
        label.frame = CGRectMake(0, self.frame.size.height-40, self.frame.size.width, 40);
        _label = label;
        
//        修改label字体大小
        label.font = [UIFont systemFontOfSize:12];
        label.numberOfLines = 1;
        label.textAlignment = NSTextAlignmentCenter;
        [self.contentView addSubview:_label];
        self.selectImageView.hidden = NO;
        self.selectPhotoButton.hidden = NO;
    }
    self.isSelected = NO;
    return _label;
}
//图片
-(UIImageView *)imageView{
    if (!_imageView ) {
        ;
        UIImageView *imageView = [[UIImageView alloc] init];
        imageView.frame = CGRectMake(0, 0, self.frame.size.width, self.frame.size.height-40);
        imageView.contentMode = UIViewContentModeScaleAspectFill;
        imageView.clipsToBounds = YES;
        [self.contentView addSubview:imageView];
        _imageView = imageView;
       
    }
    return _imageView;
}




- (void)awakeFromNib {
    
}

@end
